<text><span class="style1">his stack contains two XFCNs that deal with text in Rich Text Format, which is usually used to transfer documents between word processors while preserving formatting information. These XCMDs allow HyperCard to exchange styled text with such word processors. They also allow you to copy styled text from one HyperCard field to another, and to store styled text in variables. These XCMDs only understand the subset of RTF that deals with fonts and styles; they will ignore other formatting commands. The XCMDs only run under HyperCard 2.0 or later.The </span><span class="style5">FieldToRTF</span><span class="style1"> XFCN returns a string containing the text of a field with RTF formatting commands that describe the different fonts, point sizes, and styles in that field. You call this XFCN as: </span><span class="style5">FieldToRTF(cardflag, "fieldname")</span><span class="style1">where the first argument is </span><span class="style5">true</span><span class="style1"> if the field is a card field, and the second argument is the name of the field. If all goes well the XFCN will return the text of the field in RTF. If some error occurred, it will return a string starting with the word </span><span class="style5">error</span><span class="style1">.The </span><span class="style5">RTFToField</span><span class="style1"> XFCN takes an RTF string and puts the styled text it describes into a field. You call it as: </span><span class="style5">RTFToField(rtfText, cardflag, "fieldname")</span><span class="style1">where the first argument is the RTF string, the second is </span><span class="style5">true</span><span class="style1"> if the field is a card field, and the third is the field name. If all goes well, the text in the field will be replaced with the styled text described by the RTF, and the XFCN will return an empty string. If some error occurred, the XFCN will return an error message.For example, the following script fragment copies the contents of card field "a" to background field "b", preserving styles:</span><span class="style5"> put FieldToRTF(true, "a") into rtf if word 1 of rtf is "error" then answer rtf exit to hypercard end if get RTFToField(rtf, false, "b") if it <> "" then answer it end if</span><span class="style1">Microsoft Word will produce RTF files if you choose the Save As... menu item, click the File Format... button, and then select RTF. If you ask Word to read a text file that contains RTF, it gives you the option of converting the RTF to Word format. See the demonstration card in this stack for an example of how to read and write RTF files with HyperCard.RTF is described in the March 1987 Microsoft Systems Journal. HyperCard fields cannot represent much of the formatting described by RTF. For instance, these XFCNs ignore indentation, footnotes, page headers, and pictures. They make one extension to RTF: a \hcgroup character format property to mark HyperCard's grouped text. If you have suggestions about how to support more of RTF, please send them to the address on the first card of this stack.</span></text>
</content>
<name></name>
<script></script>
</card>
card_3052.xml
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE card PUBLIC "-//Apple, Inc.//DTD card V 2.0//EN" "" >
<script>on mouseUpset cursor to 4put "" into fld "rtf"put FieldToRTF(false, "styled") into fld "rtf"end mouseUp</script>
</part>
<part>
<id>2</id>
<type>button</type>
<visible> <true /> </visible>
<reserved5> 0 </reserved5>
<reserved4> 0 </reserved4>
<reserved3> 0 </reserved3>
<reserved2> 0 </reserved2>
<reserved1> 0 </reserved1>
<enabled> <true /> </enabled>
<rect>
<left>185</left>
<top>109</top>
<right>222</right>
<bottom>143</bottom>
</rect>
<style>rectangle</style>
<showName> <false /> </showName>
<highlight> <false /> </highlight>
<autoHighlight> <true /> </autoHighlight>
<sharedHighlight> <true /> </sharedHighlight>
<family>0</family>
<titleWidth>0</titleWidth>
<icon>4895</icon>
<textAlign>center</textAlign>
<font>Chicago</font>
<textSize>12</textSize>
<textStyle>plain</textStyle>
<name>RTF-></name>
<script>on mouseUpset cursor to 4put "" into fld "styled"put RTFToField(fld "rtf", false, "styled") into xxif xx <> "" thenanswer xxend ifend mouseUp</script>
</part>
<part>
<id>3</id>
<type>field</type>
<visible> <true /> </visible>
<dontWrap> <false /> </dontWrap>
<dontSearch> <false /> </dontSearch>
<sharedText> <false /> </sharedText>
<fixedLineHeight> <false /> </fixedLineHeight>
<autoTab> <false /> </autoTab>
<lockText> <true /> </lockText>
<rect>
<left>0</left>
<top>7</top>
<right>42</right>
<bottom>20</bottom>
</rect>
<style>transparent</style>
<autoSelect> <false /> </autoSelect>
<showLines> <false /> </showLines>
<wideMargins> <false /> </wideMargins>
<multipleLines> <false /> </multipleLines>
<reservedFamily> 0 </reservedFamily>
<titleWidth>0</titleWidth>
<icon>0</icon>
<textAlign>left</textAlign>
<font>Geneva</font>
<textSize>12</textSize>
<textStyle>bold</textStyle>
<textHeight>16</textHeight>
<name></name>
<script></script>
</part>
<part>
<id>4</id>
<type>field</type>
<visible> <true /> </visible>
<dontWrap> <false /> </dontWrap>
<dontSearch> <false /> </dontSearch>
<sharedText> <false /> </sharedText>
<fixedLineHeight> <false /> </fixedLineHeight>
<autoTab> <false /> </autoTab>
<lockText> <true /> </lockText>
<rect>
<left>0</left>
<top>137</top>
<right>37</right>
<bottom>150</bottom>
</rect>
<style>transparent</style>
<autoSelect> <false /> </autoSelect>
<showLines> <false /> </showLines>
<wideMargins> <false /> </wideMargins>
<multipleLines> <false /> </multipleLines>
<reservedFamily> 0 </reservedFamily>
<titleWidth>0</titleWidth>
<icon>0</icon>
<textAlign>left</textAlign>
<font>Geneva</font>
<textSize>12</textSize>
<textStyle>bold</textStyle>
<textHeight>16</textHeight>
<name></name>
<script></script>
</part>
<part>
<id>5</id>
<type>button</type>
<visible> <true /> </visible>
<reserved5> 0 </reserved5>
<reserved4> 0 </reserved4>
<reserved3> 0 </reserved3>
<reserved2> 0 </reserved2>
<reserved1> 0 </reserved1>
<enabled> <true /> </enabled>
<rect>
<left>78</left>
<top>240</top>
<right>178</right>
<bottom>262</bottom>
</rect>
<style>rectangle</style>
<showName> <true /> </showName>
<highlight> <false /> </highlight>
<autoHighlight> <true /> </autoHighlight>
<sharedHighlight> <true /> </sharedHighlight>
<family>0</family>
<titleWidth>0</titleWidth>
<icon>0</icon>
<textAlign>center</textAlign>
<font>Chicago</font>
<textSize>12</textSize>
<textStyle>plain</textStyle>
<name>Read RTF File</name>
<script>on mouseUpput the optionkey into optanswer file "Select an RTF file:" of type TEXTput it into flif fl is "" then exit to hypercardopen file flif opt is "down" thenset cursor to 4put "" into fld "styled"read from file fl for 100000put RTFToField(it, false, "styled") into xxif xx <> "" thenanswer xxend ifelseread from file fl for 30000put it into fld "rtf"end ifclose file flend mouseUp</script>
</part>
<part>
<id>6</id>
<type>button</type>
<visible> <true /> </visible>
<reserved5> 0 </reserved5>
<reserved4> 0 </reserved4>
<reserved3> 0 </reserved3>
<reserved2> 0 </reserved2>
<reserved1> 0 </reserved1>
<enabled> <true /> </enabled>
<rect>
<left>194</left>
<top>240</top>
<right>294</right>
<bottom>262</bottom>
</rect>
<style>rectangle</style>
<showName> <true /> </showName>
<highlight> <false /> </highlight>
<autoHighlight> <true /> </autoHighlight>
<sharedHighlight> <true /> </sharedHighlight>
<family>0</family>
<titleWidth>0</titleWidth>
<icon>0</icon>
<textAlign>center</textAlign>
<font>Chicago</font>
<textSize>12</textSize>
<textStyle>plain</textStyle>
<name>Write RTF File</name>
<script>on mouseUpask file "Write RTF to:"put it into flif fl is "" then exit to hypercardopen file flwrite fld "rtf" to file flclose file flend mouseUp</script>
</part>
<part>
<id>7</id>
<type>button</type>
<visible> <true /> </visible>
<reserved5> 0 </reserved5>
<reserved4> 0 </reserved4>
<reserved3> 0 </reserved3>
<reserved2> 0 </reserved2>
<reserved1> 0 </reserved1>
<enabled> <true /> </enabled>
<rect>
<left>340</left>
<top>238</top>
<right>378</right>
<bottom>269</bottom>
</rect>
<style>transparent</style>
<showName> <false /> </showName>
<highlight> <false /> </highlight>
<autoHighlight> <false /> </autoHighlight>
<sharedHighlight> <true /> </sharedHighlight>
<family>0</family>
<titleWidth>0</titleWidth>
<icon>2162</icon>
<textAlign>center</textAlign>
<font>Chicago</font>
<textSize>12</textSize>
<textStyle>plain</textStyle>
<name>New Button</name>
<script>on mouseUpgo card 1end mouseUp</script>
</part>
<content>
<layer>card</layer>
<id>3</id>
<text><span class="style18">ext:</span></text>
</content>
<content>
<layer>card</layer>
<id>4</id>
<text><span class="style18">TF:</span></text>
</content>
<content>
<layer>background</layer>
<id>1</id>
<text><span class="style6">irst paragraph: text in </span><span class="style23">Times</span><span class="style6"> twelve point.</span><span class="style17">Second paragraph: </span><span class="style29">Helvetica</span><span class="style17"> eighteen point. Some words in </span><span class="style30">Courier</span><span class="style52"> </span><span class="style30">underlined</span><span class="style17">.</span><span class="style3"></span></text>
</content>
<content>
<layer>background</layer>
<id>2</id>
<text>{\rtf1\mac\deff2{\fonttbl{\f2\froman New York;}{\f21\fswiss Helvetica;}{\f22\fmodern Courier;}}\plain\f2\fs24 First paragraph: text in \plain\f2\fs24\i Times\plain\f2\fs24 twelve point.\par\plain\f21\fs36 Second paragraph: \plain\f21\fs36\i Helvetica\plain\f21\fs36 eighteen point. Some words in \plain\f22\fs36\ulw Courier\plain\f22\fs36 \plain\f22\fs36\ulw underlined\plain\f21\fs36 .}</text>
</content>
<name></name>
<script></script>
</card>
card_3862.xml
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE card PUBLIC "-//Apple, Inc.//DTD card V 2.0//EN" "" >
<text><span class="style39">he XFCNs in this stack are copyright 1991 by Differential Development. They are shareware; please send $12 per copy you use to: Differential Development P.O. Box 1044 Harvard Square Station Cambridge, MA 02238In return, we will send you updates and forthcoming shareware.</span></text>
</content>
<content>
<layer>card</layer>
<id>2</id>
<text><span class="style43">TF for HyperCard</span></text>
</content>
<content>
<layer>card</layer>
<id>3</id>
<text>This stack contains software to translate between HyperCard fields and the Rich Text Format standard for styled text. You can use the software to transfer text between fields while preserving styles, to store styled text in HyperCard variables, or to read and write files that Microsoft Word can understand.</text>